package com.hns.can.master.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.hns.can.base.entity.SysCodeDscEntity;
import com.hns.can.base.entity.SysUserEntity;
import com.hns.can.base.vo.SysCodeDscVo;
import com.hns.can.common.web.BaseController;
import com.hns.can.master.service.SysCodeDscService;
import com.hns.frame.util.ResponseUtil;
import com.hns.frame.util.SpringContextUtil;
/**
 * @版权：HNS 版权所有 (c) 2013
 * @author:Fisher
 * @version Revision 1.0.0
 * @email:zhuangcaijin@126.com
 * @see:
 * @创建日期：2014-6-24
 * @功能说明：
 * @begin
 * @修改记录:
 * @修改后版本          修改人      	修改内容
 * @2014-6-24  	         Fisher        	创建
 * @end
 */
@Controller
@SessionAttributes({"SES_CURRENTUSER"})
@RequestMapping("/sysCodeDsc")
public class SysCodeDscController extends BaseController{
    
    @Autowired
    private SysCodeDscService sysCodeDscService;
    
    
    /**
     * @param request
     * @param response
     * @throws Exception
     * @author:JeffXu
     * @email:835264047@qq.com
     * @创建日期:2014-12-29
     * @功能说明：获取需要维护的代码描述的类别名称
     */
    @RequestMapping("/getSysCodeDscCategoryName")
    @ResponseBody
    public Object getSysCodeDscCategoryName(HttpServletRequest request, HttpServletResponse response) throws Exception {
        SysUserEntity user = this.getCurrentUser().getUser();
        List<SysCodeDscEntity> list = sysCodeDscService.getSysCodeDscCategoryName(user.getCorpId());
        
        return this.getReturnResult(list);
    }
    
    /**
     * @param qcodeClId
     * @param request
     * @param response
     * @throws Exception
     * @author:JeffXu
     * @email:835264047@qq.com
     * @创建日期:2014-12-29
     * @功能说明：获取对应类别下的代码描述信息
     */
    @RequestMapping("/searchSysCodeDscByCodeClId")
    @ResponseBody
    public Object searchSysCodeDscByCodeClId(String corpId, String qcodeClId) throws Exception {
        Map<String,Object> paraMap = new HashMap<String, Object>();
        paraMap.put("corpId", corpId);
        paraMap.put("qcodeClId", qcodeClId);
        List<SysCodeDscEntity> list = sysCodeDscService.searchSysCodeDscByCodeClId(paraMap);
        return this.getReturnResult(list);
    }
    
    /**
     * @param request
     * @param response
     * @throws Exception
     * @author:JeffXu
     * @email:835264047@qq.com
     * @创建日期:2014-12-29
     * @功能说明：修改代码描述信息
     */
    @RequestMapping("/uptSysCodeDsc")
    @ResponseBody
    public Object uptSysCodeDsc(SysCodeDscVo sysCodeDscVo) throws Exception {
        SysUserEntity user = this.getCurrentUser().getUser();
        sysCodeDscService.uptSysCodeDsc(user, sysCodeDscVo);
        return getReturnResult("保存成功");
    }
}
